//
//  t3d.m
//  Tekka's 3D Lib
//
//  Created by Tekka on 12-10-22.
//  Copyright (c) 2012年 Tekka. All rights reserved.
//

#import <QuartzCore/QuartzCore.h>
#import <CoreGraphics/CoreGraphics.h>

#pragma mark - backward & forward effect
/*
 * @caution: make sure you have set perspective matrix before.
 * @suggest: more powerful support please refer to the source code
 */
void t3dLayerStepBackward(CALayer* layer, CGFloat radians);
void t3dLayerStepForward(CALayer* layer, CGFloat radians);

#pragma mark - perspective projection
/*
 * @suggest: usually set perspective matrix on the superview
 */
CATransform3D t3dMatrixPerspective(CGFloat distance, CGFloat radianAgainstYAxis, CGFloat radianAgainstXAxis);
void t3dLayerPerspective(CALayer* layer, CGFloat distance, CGFloat radianAgainstYAxis, CGFloat radianAgainstXAxis);

#pragma mark - rotate against edges
/*
 * @brief: rotate against bottom line
 */
CATransform3D t3dMatrixRotateAgainstBottomLine(CGFloat degree, CGFloat halfHeight);
void t3dLayerRotateAgainstBottomLine(CALayer* layer, CGFloat degree);

/*
 * @brief: rotate against top line
 */
CATransform3D t3dMatrixRotateAgainstTopLine(CGFloat degree, CGFloat halfHeight);
void t3dLayerRotateAgainstTopLine(CALayer* layer, CGFloat degree);

/*
 * @brief: rotate against left line
 */
CATransform3D t3dMatrixRotateAgainstLeftLine(CGFloat degree, CGFloat halfWidth);
void t3dLayerRotateAgainstLeftLine(CALayer* layer, CGFloat degree);

/*
 * @brief: rotate against right line
 */
CATransform3D t3dMatrixRotateAgainstRightLine(CGFloat degree, CGFloat halfWidth);
void t3dLayerRotateAgainstRightLine(CALayer* layer, CGFloat degree);

#pragma mark - tools function
/*
 * @brief: transition between radians and degrees
 */
CGFloat t3dDegreesToRadians(CGFloat degrees);
CGFloat t3dRadiansToDegrees(CGFloat radians);
